class Solution:
    def findDuplicate(self, nums) -> int:
        tmp = set()
        for i in nums:
            if i in tmp:
                return i
            else:
                tmp.add(i)

if __name__ == '__main__':
    so = Solution()
    m = [1,3,4,2,2]
    r = so.findDuplicate(m)
    print(r)
